package com.example.xu_li_hua;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class DeserializationExample {
    public static void main(String[] args) {
        try (FileInputStream fileIn = new FileInputStream("person.ser");
             ObjectInputStream in = new ObjectInputStream(fileIn)) {
            // 读取对象
            Person person = (Person) in.readObject();
            System.out.println("反序列化对象：");
            System.out.println("姓名: " + person.getName());
            System.out.println("年龄: " + person.getAge());
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
